<template>
	<view style="height: 100vh; background-color: #FFFFFF;">
		<!-- 我的任务 -->
			<u-navbar title-color="#FFFFFF" height="48" back-icon-color="#FFFFFF" :border-bottom="false" :is-fixed="true" :title="'我的任务列表'"></u-navbar>
		<uc-content :loading="loading">
			<!--无数据列表页面-->
			<view v-if="taskList.length<1" class="view-center">
				<u-empty text="我的任务数据为空" mode="list"></u-empty>
			</view>
			<view v-else>
				<view class="list-item" v-for="(item,index) in taskList" :key="index" @click="checkItem(item)">
					<view class="list-top ">
						<view class="list-left">{{ item.name }}</view>
					</view>
					<view class="list-center u-line-3">
						<view>类型:{{item.type | type}}</view>
						<view>描述:{{item.remark}}</view>
						<view>执行时间:{{item.startTime | taskDate}}--{{item.endTime | taskDate}}</view>
						<view class="u-line-2">内容:{{item.content}}</view>
					</view>
				</view>
				<u-loadmore :status="status" :icon-type="iconType" :load-text="loadText" />
			</view>
		</uc-content>
	
	</view>
</template>

<script>
	export default {
		data() {
			return {
				loading:false,
				taskList: {},
				pageNum:0,
				finished:false,
				status: 'loadmore',
				iconType: 'flower',
				loadText: {
					loadmore: '轻轻上拉',
					loading: '努力加载中',
					nomore: '没有更多数据了'
				},
			}
		},
		onShow() {
			this.initView()
		},
		methods: {
			initView() {
				this.loading=true
				this.taskList = {}
				this.pageNum = 0
				this.getTaskEnterprisePage()
			},
			checkItem(item) {
				if(item.type==0 || item.type==10){
					uni.navigateTo({
						url: '/pages/index/task/patrolInfo?ucId='+item.ucId,
					});
				}else{
					uni.navigateTo({
						url: '/pages/index/task/info?ucId='+item.ucId,
					});
				}
			},
			//获取分页信息数据
			getTaskEnterprisePage(){
				this.pageNum++
				console.log(this.pageNum)
				let _this = this
				return new Promise((resolve, reject) => {
					_this.utils.request("/api/app/task/getTaskEnterprisePage", {pageNum:this.pageNum,pageSize:10,status:1}, "post", "app", true).then(res => {
						_this.taskList=res.data.list
						_this.finished = (res.data.pageNum >= res.data.pages);
						if(_this.finished){
							_this.status = 'nomore';
						}
						this.loading=false
						resolve(res)
					}).catch(error => {
						this.loading=false
						reject(error)
					})
				})
			},
			onReachBottom() {
				if(this.finished) return ;
				this.status = 'loading';
				this.getInDailyTasksPage().then(res=>{
					if(this.finished) this.status = 'nomore';
					else this.status = 'loading';
				}).catch(error=>{
					this.status = 'nomore';
				})
			},
			
		}
	}
</script>


<style lang="scss" scoped>
	@import "../../../uview-ui/libs/css/style.components.scss";

	.list-item {
		padding: 30rpx 40rpx;
		background-color: #fff;
		border-bottom: #999999 1px solid;

		.list-top {
			@include vue-flex;
			justify-content: space-between;
			align-items: center;

			.list-left {
				font-weight: bold;
				font-size: 34rpx;
			}

			.list-right {
				font-size: 30rpx;
				line-height: 34rpx;
				color: #999999;
			}
		}

		.list-center {
			margin-top: 20rpx;
			font-size: 28rpx;
			color: #999999;
		}

		.list-bottom {
			display: flex;
			margin-top: 20rpx;
			font-size: 28rpx;
			justify-content: space-between;
			color: #999999;
		}
	}
</style>
